<?php

use think\migration\Migrator;
use think\migration\db\Column;

/**
 * 系统配置迁移类
 * Class SystemConfig
 */
class SystemConfig extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('system_config', ['comment' => '配置表', 'engine' => 'InnoDB']);
        $table->addColumn('name', 'string', ['default' => '', 'comment' => '字段名称'])
            ->addColumn('type', 'string', ['default' => '', 'comment' => '类型（文本框,单选按钮...）'])
            ->addColumn('input_type', 'string', ['default' => 'input', 'comment' => '表单类型'])
            ->addColumn('config_tab_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '配置分类 ID'])
            ->addColumn('parameter', 'string', ['default' => '', 'comment' => '规则 单选框和多选框'])
            ->addColumn('upload_type', 'boolean', ['limit' => 1, 'default' => 0, 'comment' => '上传文件格式 1：单图 2：多图 3：文件'])
            ->addColumn('required', 'string', ['default' => '', 'comment' => '规则'])
            ->addColumn('width', 'integer', ['limit' => 10, 'comment' => '多行文本框的宽度'])
            ->addColumn('high', 'integer', ['limit' => 10, 'comment' => '多行文框的高度'])
            ->addColumn('value', 'string', ['limit' => 5000, 'comment' => '默认值'])
            ->addColumn('info', 'string', ['default' => '', 'comment' => '配置名称'])
            ->addColumn('desc', 'string', ['comment' => '配置简介'])
            ->addColumn('sort', 'integer', ['limit' => 10, 'comment' => '排序'])
            ->addColumn('status', 'boolean', ['limit' => 1, 'comment' => '是否隐藏 0：否 1：是'])
            ->create();
    }
}
